// 权限查询
const DataBaseconnections = require('../app/database')
class AuthService {
  async checkMoment(momentId, userId) {
    //   1.具备权限发挥true
    //   2.不具备权限返回false
    const statement = `SELECT
                            * 
                        FROM
                            moment 
                        WHERE
                            moment.id = ? && moment.user_id = ?;`
    // 将user存入数据库
    const results = await DataBaseconnections.execute(statement, [momentId, userId])
    if (results[0][0]) {
      return true
    } else {
      return false
    }
  }
}

module.exports = new AuthService()
